package com.zhangyue.web.service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.zhangyue.web.model.User;

import java.util.List;

public class UserService {
    public static UserService userService = new UserService();
    private User dao = new User().dao();

    public void add(User user){
        user.save();
    }

    public void update(User user){
        user.update();
    }

    public void delete(int id){
        dao.deleteById(id);
    }

    public User findById(int id){
         return dao.findFirst("select * from t_user where id=?",id);
    }

    public Page<User> paginate(int pageNumber, int pageCount){
        return dao.paginate(pageNumber,pageCount,"select * " ,"from t_user");
    }
}